package cn.tedu.finalx;

public class FinalDemo {
    public static final int MIN;
    static{
        MIN = 8;
    }

    public static void main(String[] args) {
//        final int NUM = 6;
//        new A().changeValue(NUM);
//        System.out.println(NUM);
//
//        final B B_B = new B();
//        new A().changRef(B_B);
//        System.out.println(B_B.num);
//        B_B.num = 8;//常量指向的对象的属性值
//        System.out.println(B_B.num);//8
//        B_B = new B();//编译会报错

        //向上造型
//        Father father = new Son();
//        father.method();//编译左边 运行看右边
//        get(new Father());
//        get(new Son());

//        int num = 5;
        String name = "hello hi hello";
        System.out.println(name.length());
    }
    public static void get(Father father){
        father.getMoney();
    }
}
/*final */class Father{
    public void method(){
        System.out.println("Father method方法");
    }
    public final void getMoney(){
        System.out.println("10000元");
    }
//    public final void getMoney(int money){
//        System.out.println("10000元");
//    }
}
class Son extends Father{
    @Override
    public void method() {
        System.out.println("Son method方法");
    }

//    public final void getMoney() {
//        System.out.println("10元");
//    }
}
//class A{
//    //final int NUM = 6;//常量
//    //先声明后赋值
//    //final int MAX;
////    {
////        MAX = 8;
////    }
////    public A(){
////        MAX = 8;
////    }
//
////    {
////        //NUM = 8;
////    }
//    public void changeValue(int n){
//        //MAX = 8;
//        n = 9;
//    }
//    public void changRef(B b){
//        b = new B();
//    }
//}
//class B{
//    int num;
//}
